package cn.csdj.sism.web;

import cn.csdj.sism.pojo.CGrade;
import cn.csdj.sism.service.CGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 成绩控制器
 * 夏康
 */
@CrossOrigin
@RestController
@RequestMapping("/cgrade")
public class CGradeController {
    //注入成绩业务层
    @Autowired
    CGradeService cGradeService;
    //添加成绩
    @PostMapping
    public void insert(@RequestBody CGrade cGrade){
        cGradeService.insert(cGrade);
    }
    //根据id删除成绩
    @DeleteMapping("/{id}")
    public void deleteById(@PathVariable Integer id){
        cGradeService.deleteById(id);
    }
    //修改成绩
    @PutMapping
    public void update(@RequestBody CGrade cGrade){
        cGradeService.update(cGrade);
    }
    //根据id查询成绩
    @GetMapping("/{id}")
    public CGrade selectById(@PathVariable Integer id){
        return cGradeService.selectById(id);
    }
    //查询所有成绩
    @GetMapping
    public List<CGrade> selectAll(){
        return cGradeService.selectAll();
    }
}
